package com.qzyh.esb.egsa.config;

import com.qzyh.esb.egsa.interceptor.TokenInterceptor;
import com.qzyh.esb.egsa.interceptor.UrlInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Resource
    private UrlInterceptor urlInterceptor;

    @Resource
    private TokenInterceptor tokenInterceptor;


    public void addInterceptors(InterceptorRegistry registry) {
        String[] addPathPatterns = {
                "/**"
        };
        registry.addInterceptor(urlInterceptor).addPathPatterns(addPathPatterns);
        registry.addInterceptor(tokenInterceptor).addPathPatterns(addPathPatterns).excludePathPatterns(
                "/login/index",
                "/login/publicKey",
                "/swagger-ui/**",
                "/swagger-resources/**",
                "/v2/**"
        );
    }
}
